CFLAGS = -Wall -g
LDFLAGS = -lreadline -lpthread
OBJECTS = main.o iuMacAddress.o iuIPAddress.o iuPacket.o iuPacketRaw.o iuPacketEthernet.o iuPacketIP.o iuPacketARP.o iuPacketICMP.o iuPacketFactory.o \
          iuRoute.o iuARPTable.o iuInterface.o iuInterfaceFifo.o iuInterfaceSocket.o iuModuleIP.o iuModuleARP.o iuModuleICMP.o iuApplication.o \
          iuShell.o iuCommandInterface.o iuCommandIfconfig.o iuCommandArp.o iuCommandRoute.o iuCommandPing.o

all: IPoUDP HubFifo

HubFifo: hub_fifo.c
	gcc -o HubFifo hub_fifo.c $(CFLAGS)

IPoUDP: $(OBJECTS)
	g++ -o IPoUDP $(OBJECTS) $(LDFLAGS)

main.o: main.cpp iuApplication.hpp
	g++ -c -o main.o main.cpp $(CFLAGS)

iuMacAddress.o: iuMacAddress.cpp iuMacAddress.hpp iuIPAddress.hpp
	g++ -c -o iuMacAddress.o iuMacAddress.cpp $(CFLAGS)

iuIPAddress.o: iuIPAddress.cpp iuIPAddress.hpp
	g++ -c -o iuIPAddress.o iuIPAddress.cpp $(CFLAGS)

iuPacketFactory.o: iuPacketFactory.cpp iuPacketFactory.hpp iuPacket.hpp
	g++ -c -o iuPacketFactory.o iuPacketFactory.cpp $(CFLAGS)

iuPacketEthernet.o: iuPacketEthernet.cpp iuPacketEthernet.hpp iuPacket.hpp iuMacAddress.hpp iuPacketFactory.hpp
	g++ -c -o iuPacketEthernet.o iuPacketEthernet.cpp $(CFLAGS)

iuPacket.o: iuPacket.cpp iuPacket.hpp
	g++ -c -o iuPacket.o iuPacket.cpp $(CFLAGS)

iuPacketRaw.o: iuPacketRaw.cpp iuPacketRaw.hpp
	g++ -c -o iuPacketRaw.o iuPacketRaw.cpp $(CFLAGS)

iuPacketIP.o: iuPacketIP.cpp iuPacketIP.hpp iuPacket.hpp iuPacketFactory.hpp
	g++ -c -o iuPacketIP.o iuPacketIP.cpp $(CFLAGS)

iuPacketARP.o: iuPacketARP.cpp iuPacketARP.hpp iuPacket.hpp iuMacAddress.hpp
	g++ -c -o iuPacketARP.o iuPacketARP.cpp $(CFLAGS)

iuPacketICMP.o: iuPacketICMP.cpp iuPacketICMP.hpp iuPacket.hpp
	g++ -c -o iuPacketICMP.o iuPacketICMP.cpp $(CFLAGS)

iuRoute.o: iuRoute.cpp iuRoute.hpp iuRouteRule.hpp iuInterface.hpp iuIPAddress.hpp
	g++ -c -o iuRoute.o iuRoute.cpp $(CFLAGS)

iuARPTable.o: iuARPTable.cpp iuARPTable.hpp iuARPEntry.hpp iuMacAddress.hpp iuIPAddress.hpp
	g++ -c -o iuARPTable.o iuARPTable.cpp $(CFLAGS)

iuInterface.o: iuInterface.cpp iuInterface.hpp iuMacAddress.hpp iuIPAddress.hpp iuPacketEthernet.hpp
	g++ -c -o iuInterface.o iuInterface.cpp $(CFLAGS)

iuInterfaceFifo.o: iuInterfaceFifo.cpp iuInterfaceFifo.hpp iuInterface.hpp iuMacAddress.hpp iuIPAddress.hpp
	g++ -c -o iuInterfaceFifo.o iuInterfaceFifo.cpp $(CFLAGS)

iuInterfaceSocket.o: iuInterfaceSocket.cpp iuInterfaceSocket.hpp iuInterface.hpp iuMacAddress.hpp iuIPAddress.hpp
	g++ -c -o iuInterfaceSocket.o iuInterfaceSocket.cpp $(CFLAGS)

iuShell.o: iuShell.cpp iuShell.hpp
	g++ -c -o iuShell.o iuShell.cpp $(CFLAGS)

iuCommandInterface.o: iuCommandInterface.cpp iuCommandInterface.hpp iuCommand.hpp iuApplication.hpp iuInterface.hpp
	g++ -c -o iuCommandInterface.o iuCommandInterface.cpp $(CFLAGS)

iuCommandIfconfig.o: iuCommandIfconfig.cpp iuCommandIfconfig.hpp iuCommand.hpp iuApplication.hpp iuInterface.hpp iuMacAddress.hpp iuIPAddress.hpp
	g++ -c -o iuCommandIfconfig.o iuCommandIfconfig.cpp $(CFLAGS)

iuCommandPing.o: iuCommandPing.cpp iuCommandPing.hpp iuCommand.hpp iuApplication.hpp iuPacketICMP.hpp iuPacketIP.hpp iuModuleIP.hpp iuIPAddress.hpp
	g++ -c -o iuCommandPing.o iuCommandPing.cpp $(CFLAGS)

iuCommandRoute.o: iuCommandRoute.cpp iuCommandRoute.hpp iuCommand.hpp iuApplication.hpp iuModuleIP.hpp iuRoute.hpp iuRouteRule.hpp iuInterface.hpp
	g++ -c -o iuCommandRoute.o iuCommandRoute.cpp $(CFLAGS)

iuCommandArp.o: iuCommandArp.cpp iuCommandArp.hpp iuCommand.hpp iuApplication.hpp iuARPTable.hpp
	g++ -c -o iuCommandArp.o iuCommandArp.cpp $(CFLAGS)

iuApplication.o: iuApplication.cpp iuApplication.hpp iuInterface.hpp iuInterfaceFifo.hpp iuInterfaceSocket.hpp \
                 iuShell.hpp iuCommand.hpp iuCommandInterface.hpp iuCommandIfconfig.hpp iuCommandRoute.hpp iuCommandPing.hpp iuCommandArp.hpp \
                 iuModuleIP.hpp iuModuleARP.hpp iuPacket.hpp
	g++ -c -o iuApplication.o iuApplication.cpp $(CFLAGS)

iuModuleIP.o: iuModuleIP.cpp iuModuleIP.hpp iuPacket.hpp iuPacketIP.hpp iuApplication.hpp iuInterface.hpp iuModuleICMP.hpp iuMacAddress.hpp
	g++ -c -o iuModuleIP.o iuModuleIP.cpp $(CFLAGS)

iuModuleARP.o: iuModuleARP.cpp iuModuleARP.hpp iuPacket.hpp iuPacketARP.hpp iuInterface.hpp iuIPAddress.hpp iuMacAddress.hpp
	g++ -c -o iuModuleARP.o iuModuleARP.cpp $(CFLAGS)

iuModuleICMP.o: iuModuleICMP.cpp iuModuleICMP.hpp iuPacket.hpp iuPacketIP.hpp iuPacketICMP.hpp iuModuleIP.hpp
	g++ -c -o iuModuleICMP.o iuModuleICMP.cpp $(CFLAGS)

clean:
	rm IPoUDP *.o
